package org.meteorshower.employee_depart.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.meteorshower.employee_depart.util.UUIDGenerator;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * 默认字段数据插入配置
 * */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createDate", new Date(), metaObject);
        this.setFieldValByName("id", UUIDGenerator.setUUID(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateDate", new Date(), metaObject);
    }
}
